package br.inf.ufrgs.usixml4cdc.main;

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import br.inf.ufrgs.br.usixml4cdc.rendering.UsiXMLInterfaceRenderer;
import br.inf.ufrgs.br.usixml4cdc.rendering.javadesktop.UsiXMLJavaDesktopInterfaceRenderer;
import br.inf.ufrgs.usixml4cdc.document.UsiXMLDocument;
import br.inf.ufrgs.usixml4cdc.exceptions.ParsingErrorException;
import br.inf.ufrgs.usixml4cdc.exceptions.RenderingErrorException;

public class Main {
	
	private static Main _instance;
	private File usixmlDocumentFile = new File("D:/frk/Projetos Software/UsiXML4ALL/UsiXML4Desktop/resources/Calculator/calculator2.usi");
	
	private UsiXMLInterfaceRenderer defaultRenderer = new UsiXMLJavaDesktopInterfaceRenderer();
	
	 public static Main getInstance(){
	        if (_instance == null) {
	            _instance = new Main();
	        }
	        
	        return _instance;
	    }
	
	public static void main(String[] args) {
		
		Main usixml4cdc = Main.getInstance();
		UsiXMLDocument usiXMLDocument = null;
		try {
			usiXMLDocument = new UsiXMLDocument(usixml4cdc.usixmlDocumentFile);
			
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
		
		try {
			usixml4cdc.defaultRenderer.createUserInterface(
					usiXMLDocument.getCuiModelElement(),
					usiXMLDocument.getContextModelElement(),
					usiXMLDocument.getResourceModelElement());
		} catch (RenderingErrorException e) {
			e.printStackTrace();
		} catch (ParsingErrorException e) {
			e.printStackTrace();
		}
	

	}

}
